package com.example.springboot.exceptionInfo;

import com.example.springboot.utils.vo.RstData;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@ControllerAdvice
public class GlobalExceptionHandler {
//
//    @ResponseBody
//    @ExceptionHandler(value = BeetlSQLException.class)
//    public RstData beetlSQLException(HttpServletRequest req, BeetlSQLException e) {
//        return RstData.faild(EnumResult.FAILED, e.getMessage());
//    }

    @ResponseBody
    @ExceptionHandler(value = ExceptionInfoType.class)
    public RstData frsException(HttpServletRequest req, ExceptionInfoType e) {
        return RstData.faild(e);
    }

    @ResponseBody
    @ExceptionHandler(value = Exception.class)
    public RstData frsException(HttpServletRequest req, Exception e) {
        return RstData.faild(e.toString());
    }
}
